/////////////////////////////////////////////////////////////////////////////
// CByteStream
//
class  CByteStream
{
public :
	CByteStream();
	~CByteStream();
	CByteStream(unsigned char* pBuf);

public :
	long Seek(long lPos);
	long Tell();
	unsigned char* GetData();

	void Write(void* pData, long lSize);
	void Read(void* pData, long lSize);
   void SetType(short type); 

	CByteStream& operator << (unsigned char ch);
	CByteStream& operator << (char ch);
	CByteStream& operator << (short s);
	CByteStream& operator << (unsigned short s);
	CByteStream& operator << (int i);
	CByteStream& operator << (unsigned int i);
	CByteStream& operator << (long l);
	CByteStream& operator << (unsigned long l);
	CByteStream& operator << (float f);
	CByteStream& operator << (double d);

	CByteStream& operator >> (unsigned char& ch);
	CByteStream& operator >> (char& ch);
	CByteStream& operator >> (short& s);
	CByteStream& operator >> (unsigned short& s);
	CByteStream& operator >> (int& i);
	CByteStream& operator >> (unsigned int& i);
	CByteStream& operator >> (long& l);
	CByteStream& operator >> (unsigned long& l);
	CByteStream& operator >> (float& f);
	CByteStream& operator >> (double& d);

	static unsigned char ReadUChar(unsigned char* pBuf, long off);
	static char ReadChar(unsigned char* pBuf, long off);
	static unsigned short ReadUShort(unsigned char* pBuf, long off);
	static short ReadShort(unsigned char* pBuf, long off);
	static unsigned int ReadUInt(unsigned char* pBuf, long off);
	static int ReadInt(unsigned char* pBuf, long off);
	static unsigned long ReadULong(unsigned char* pBuf, long off);
	static long ReadLong(unsigned char* pBuf, long off);
	static float ReadFloat(unsigned char* pBuf, long off);
	static double ReadDouble(unsigned char* pBuf, long off);

	static int WriteUChar(unsigned char* pBuf, long off, unsigned char ch);
	static int WriteChar(unsigned char* pBuf, long off, char ch);
	static int WriteUShort(unsigned char* pBuf, long off, unsigned short s);
	static int WriteShort(unsigned char* pBuf, long off, short s);
	static int WriteUInt(unsigned char* pBuf, long off, unsigned int i);
	static int WriteInt(unsigned char* pBuf, long off, int i);
	static int WriteULong(unsigned char* pBuf, long off, unsigned long l);
	static int WriteLong(unsigned char* pBuf, long off, long l);
	static int WriteFloat(unsigned char* pBuf, long off, float f);
	static int WriteDouble(unsigned char* pBuf, long off, double d);

private :
	unsigned char* m_pBuf;
	long m_lCurPos;
};

class CMyStream : public CByteStream
{
    public:
        CMyStream(char *pBuf);
        CMyStream();
        ~CMyStream();
    public:
        void SetText(char *pData);
        void GetText(char *pData, long len);
};

